package com.example.server.Service;

import com.example.server.entity.Lunboplace;
import com.example.server.entity.Place;
import com.example.server.mapper.Placemapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@Service
public class PlaceService {
    @Autowired
   private Placemapper placemapper;
    public  boolean selectplace(String fileName) { //查询地点是否重复
        return placemapper.selectplace(fileName);
    }

    public List<Place> getallplace() {
        return placemapper.getplace();
    }

    public List<Lunboplace> getlunbo() {
        return placemapper.getlunboplace();
    }

    public List<Place> smallfindby(String type) {
        return placemapper.findsmall(type);
    }

    public List<Place> getsearch(String type, String searchtext) {

        switch (type){
            case "city":
                return placemapper.cityselect(searchtext);
            case "publisher":
                return placemapper.personselect(searchtext);
            case "destination":
                return placemapper.placeselect(searchtext);
            default: return null;
        }
    }
    //插入新的景色地点
    public boolean insertplace(String locationName, String FileName, String type, String city, String uploader, String now, String description) {
    return placemapper.insertplace(locationName,FileName,type,city,uploader,now,description);
    }

    public List<Place> uidgetplace(String uid) {
        return placemapper.uidgetplace(uid);
    }

    public int getplace() {
        return placemapper.select();
    }

    public int deleteplace(int id) {
        return placemapper.delete(id);
    }

    public boolean addlunbo(int id) {
        int a = placemapper.selectlunboplace(id);
        if(a==1)//已经存在！
            return false;
        return placemapper.addlunbo(id);
    }

    public int deletelunbo(String id) {
        return placemapper.deletelunbo(id);
    }

    public int selectlunbopla(int id) {
        return placemapper.selectlunboplace(id);
    }
}
